package guiElements;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Point;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class ColorSelectorPanel extends JPanel {

	
	private MultiColorSelector multi;
	private ColorSelector black, blue, brown, burgundy, gold, green, orange,
	pink, purple, red, silver, tan, white, yellow;
	
	public ColorSelectorPanel() {
		setLayout(null);
		setBackground(Color.white);
		JPanel title = new JPanel();
		title.setBackground(Color.white);
		title.setSize(new Dimension(550, 25));
		title.setLocation(new Point(0,0));
		JLabel titleLabel = new JLabel("Select Colors:");
		titleLabel.setFont(new Font("Georgia", Font.BOLD, 14));
		title.setLayout(null);
		titleLabel.setSize(new Dimension(100,12));
		titleLabel.setLocation(new Point(0,0));
		title.add(titleLabel);
		
		JPanel selector = new JPanel();
		selector.setSize(new Dimension(550,225));
		selector.setLocation(new Point(0,25));
		selector.setLayout(new GridLayout(5,3));
		multi = new MultiColorSelector("Multiple");
		selector.add(multi);
		black = new ColorSelector("Black", 0,0,0);
		selector.add(black);
		blue = new ColorSelector("Blue", 0,0,255);
		selector.add(blue);
		brown = new ColorSelector("Brown", 69,51,18);
		selector.add(brown);
		burgundy = new ColorSelector("Burgundy", 112,11,47);
		selector.add(burgundy);
		gold = new ColorSelector("Gold", 227,195,16);
		selector.add(gold);
		green = new ColorSelector("Green", 0,220,0);
		selector.add(green);
		orange = new ColorSelector("Orange", 252,144,3);
		selector.add(orange);
		pink = new ColorSelector("Pink", 242,107,177);
		selector.add(pink);
		purple = new ColorSelector("Purple", 115,19,133);
		selector.add(purple);
		red = new ColorSelector("Red", 255,0,0);
		selector.add(red);
		silver = new ColorSelector("Silver", 180,180,180);
		selector.add(silver);
		tan = new ColorSelector("Tan", 209,179,113);
		selector.add(tan);
		white = new ColorSelector("White", 255,255,255);
		selector.add(white);
		yellow = new ColorSelector("Yellow", 255,255,80);
		selector.add(yellow);
		
		add(title);
		add(selector);

	}
	
	public ArrayList<String> getSelectedColors(){
		ArrayList<String> selectedColors = new ArrayList<String>(0);
		if(multi.colorSelected()!=null){
			selectedColors.add(multi.colorSelected());
		}
		if(black.colorSelected()!=null){
			selectedColors.add(black.colorSelected());
		}
		if(blue.colorSelected()!=null){
			selectedColors.add(blue.colorSelected());
		}
		if(brown.colorSelected()!=null){
			selectedColors.add(brown.colorSelected());
		}
		if(burgundy.colorSelected()!=null){
			selectedColors.add(burgundy.colorSelected());
		}
		if(gold.colorSelected()!=null){
			selectedColors.add(gold.colorSelected());
		}
		if(green.colorSelected()!=null){
			selectedColors.add(green.colorSelected());
		}
		if(orange.colorSelected()!=null){
			selectedColors.add(orange.colorSelected());
		}
		if(pink.colorSelected()!=null){
			selectedColors.add(pink.colorSelected());
		}
		if(purple.colorSelected()!=null){
			selectedColors.add(purple.colorSelected());
		}
		if(red.colorSelected()!=null){
			selectedColors.add(red.colorSelected());
		}
		if(silver.colorSelected()!=null){
			selectedColors.add(silver.colorSelected());
		}
		if(tan.colorSelected()!=null){
			selectedColors.add(tan.colorSelected());
		}
		if(white.colorSelected()!=null){
			selectedColors.add(white.colorSelected());
		}
		if(yellow.colorSelected()!=null){
			selectedColors.add(yellow.colorSelected());
		}
		return selectedColors;
		
	}

	public void reset() {
		multi.getColorCheckBox().setSelected(false);
		black.getColorCheckBox().setSelected(false);
		blue.getColorCheckBox().setSelected(false);
		brown.getColorCheckBox().setSelected(false);
		burgundy.getColorCheckBox().setSelected(false);
		gold.getColorCheckBox().setSelected(false);
		green.getColorCheckBox().setSelected(false);
		orange.getColorCheckBox().setSelected(false);
		pink.getColorCheckBox().setSelected(false);
		purple.getColorCheckBox().setSelected(false);
		red.getColorCheckBox().setSelected(false);
		silver.getColorCheckBox().setSelected(false);
		tan.getColorCheckBox().setSelected(false);
		white.getColorCheckBox().setSelected(false);
		yellow.getColorCheckBox().setSelected(false);
	}

}
